/* --------------------------------------------------------
 * Copyright (c) aeky , Inc.  All rights reserved.
 * --------------------------------------------------------
 */
package com.aeky.client.mvc;

/**
 * TODO
 * 
 * @author aeky
 */
public class BaseEvent {
    private boolean cancelled;
    private Object source;
    private EventType type;

    public BaseEvent(EventType type) {
        this.type = type;
    }

    /**
     * Returns true if the operation is being cancelled.
     * 
     * @return true if cancelled
     */
    public boolean isCancelled() {
        return cancelled;
    }

    /**
     * True to cancel the current operation (defaults to false). Only applies to
     * events that can be cancelled as defined by the object firing the event.
     * Canceling an operation does not stop all listeners from being notified of
     * the event.
     * 
     * @param cancelled true to cancel
     */
    public void setCancelled(boolean cancelled) {
        this.cancelled = cancelled;
    }

    /**
     * Creates a new base event instance.
     * 
     * @param source the source object
     */
    public BaseEvent(Object source) {
        this.source = source;
    }

    /**
     * Returns the object that fired the event.
     * 
     * @return the object that fired the event
     */
    public Object getSource() {
        return source;
    }

    /**
     * Returns the event's event type.
     * 
     * @return the event type
     */
    public EventType getType() {
        return type;
    }

    /**
     * Sets the object that fired the event.
     * 
     * @param source the source object
     */
    public void setSource(Object source) {
        this.source = source;
    }

    /**
     * Sets the event's event type.
     * 
     * @param type the event type
     */
    public void setType(EventType type) {
        this.type = type;
    }
}
